@extends('adminer.admin')
@section("style")
    <link rel="stylesheet" type="text/css" href="/assets/nestable/jquery.nestable.css" />
    <style>
        .btn{ padding: 3px 12px;}
        .dropdown-menu {min-width: 123px;}
        .btn-warning {float: right; position: relative; top:4px; right:10px;}
    </style>
@endsection
@section('content')
    <!-- BEGIN PAGE HEADER-->
    @include("adminer.public.bread")
    <!-- END PAGE HEADER-->
    <!-- BEGIN PAGE CONTENT-->
    <div class="row-fluid">
        <div class="span12">
            <div class="widget">
                <div class="widget-title">
                    <h4><i class="icon-align-left"></i>{{$title}}</h4>
                    <a class="btn btn-warning" href="{{route('purview.create')}}"><i class="icon-plus icon-white"></i> 添加新权限</a>
                </div>
                <div class="widget-body">
                    <div class="dd" id="nestable_list_1">
                        <?=$html?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- END PAGE CONTENT-->
@endsection
@section("script")
    <script>
        jQuery(document).ready(function() {
            // initiate layout and plugins
            App.init();
            UINestable.init();
        });
        function show_info(id){
            var html = "";
            $.get('/manage/purview/'+id,function(data){
                if(data.code == 200){
                    html = '<div class="widget-body">\n' +
    '                            <table class="table table-striped table-hover">\n' +
    '                                <tbody>\n' +
    '                                <tr>\n' +
    '                                    <td><span class="label label-success">权限名称</span></td>\n' +
    '                                    <td>'+data.data.title+'</td>\n' +
    '                                </tr>\n' +
    '                                <tr>\n' +
    '                                    <td><span class="label label-success">权限ID</span></td>\n' +
    '                                    <td>'+data.data.pid+'</td>\n' +
    '                                </tr>\n' +
    '                                <tr>\n' +
    '                                    <td><span class="label label-success">URL地址</span></td>\n' +
    '                                    <td>'+data.data.url+'</td>\n' +
    '                                </tr>\n' +
    '                                <tr>\n' +
    '                                    <td><span class="label label-success">功能</span></td>\n' +
    '                                    <td>'+data.data.func+'</td>\n' +
    '                                </tr>\n' +
    '                                </tbody>\n' +
    '                            </table>\n' +
    '                        </div>';
                    layer.open({
                        title:"详情",
                        type: 1,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['450px', '260px'], //宽高
                        content: html
                    });
                }else{
                    layer.alert(data.message);
                }

            })

        }
        $('#nestable_list_1').nestable().on('change', function(){
            var r = $(this).nestable('serialize');
            $.post('{{route('purview.sort')}}',{data:JSON.stringify(r)},function(data){
                console.log(data);
            })
        });
    </script>
@endsection